//
//  UserCenterHeadView.m
//  ProjectforHDX
//
//  Created by Jaesun on 16/7/5.
//  Copyright © 2016年 H.DX. All rights reserved.
//

#import "UserCenterHeadView.h"

@implementation UserCenterHeadView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self s_setupViews];
    }
    return  self;
}

- (void)s_setupViews {
    
    // 返回按钮
    _leftBtn = [RZCustomButtom buttonWithType:(UIButtonTypeCustom)];
 
    [self addSubview:_leftBtn];
    
    // 用户头像
 
    _photoView = [[RZCustomImageView alloc] init];
 
    [self addSubview:_photoView];
    
    // 用户名和工号
    _nameLabel = [[RZCustomLable alloc] init];
    _nameLabel.font = CustomFont(14.5);
    _nameLabel.textAlignment = NSTextAlignmentCenter;
    _nameLabel.text = @"张旭 12002";
    _nameLabel.textColor = [THMangerTool hexStringToColor:@"ffffff" alpha:1];
    [self addSubview:_nameLabel];
    
    
}

- (void)layoutSubviews {
    
    // 返回按钮
    UIImage *leftImg = BDFILEIMAGENAEM(@"default/iconfont-fanhui");
    [_leftBtn setImage:leftImg forState:UIControlStateNormal];
    _leftBtn.frame = CGRectMake(10, 30, 34, 34);
 
    // 用户头像

    UIImage *photoImg = BDFILEIMAGENAEM(@"UserCenter/photoHolder");
    CGFloat topToSuperViewPadding = 50.0f;
    _photoView.frame = CGRectMake((self.width - photoImg.size.width) / 2, topToSuperViewPadding,photoImg.size.width, photoImg.size.height);
    [_photoView addRadius:photoImg.size.width / 2 borderwidth:2 bordercolor:[UIColor whiteColor]];
    
    CGFloat topToPhotoViewPadding = 20.0f;
    CGFloat nameLabelWidth = 140;
    _nameLabel.frame = CGRectMake(self.width / 2 - nameLabelWidth / 2,_photoView.bottom + topToPhotoViewPadding, nameLabelWidth , 20);
    
}

@end
